package com.ruoyi.mall.sms.service.impl;

import com.ruoyi.mall.pms.mapper.PmsProductMapper;
import com.ruoyi.mall.sms.domain.SmsFlashPromotionProductRelation;
import com.ruoyi.mall.sms.mapper.SmsFlashPromotionProductRelationMapper;
import com.ruoyi.mall.sms.service.ISmsFlashPromotionProductRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 商品限时购与商品关系Service业务层处理
 *
 * @author xuxing
 * @date 2021-02-09
 */
@Service
public class SmsFlashPromotionProductRelationServiceImpl implements ISmsFlashPromotionProductRelationService
{
    @Autowired
    private SmsFlashPromotionProductRelationMapper smsFlashPromotionProductRelationMapper;

    @Autowired
    private PmsProductMapper pmsProductMapper;

    /**
     * 查询商品限时购与商品关系
     *
     * @param id 商品限时购与商品关系ID
     * @return 商品限时购与商品关系
     */
    @Override
    public SmsFlashPromotionProductRelation selectSmsFlashPromotionProductRelationById(Long id)
    {
        return smsFlashPromotionProductRelationMapper.selectSmsFlashPromotionProductRelationById(id);
    }

    /**
     * 查询商品限时购与商品关系列表
     *
     * @param smsFlashPromotionProductRelation 商品限时购与商品关系
     * @return 商品限时购与商品关系
     */
    @Override
    public List<SmsFlashPromotionProductRelation> selectSmsFlashPromotionProductRelationList(SmsFlashPromotionProductRelation smsFlashPromotionProductRelation)
    {
        return smsFlashPromotionProductRelationMapper.selectSmsFlashPromotionProductRelationList(smsFlashPromotionProductRelation);
    }

    /**
     * 新增商品限时购与商品关系
     *
     * @param smsFlashPromotionProductRelationList 商品限时购与商品关系
     * @return 结果
     */
    @Override
    @Transactional
    public int insertSmsFlashPromotionProductRelation(List<SmsFlashPromotionProductRelation> smsFlashPromotionProductRelationList)
    {
        int rows = 0;
        for (SmsFlashPromotionProductRelation smsFlashPromotionProductRelation : smsFlashPromotionProductRelationList) {
            int i = smsFlashPromotionProductRelationMapper.insertSmsFlashPromotionProductRelation(smsFlashPromotionProductRelation);
            rows = rows + i;
        }
        return rows;
    }

    /**
     * 修改商品限时购与商品关系
     *
     * @param smsFlashPromotionProductRelation 商品限时购与商品关系
     * @return 结果
     */
    @Override
    public int updateSmsFlashPromotionProductRelation(SmsFlashPromotionProductRelation smsFlashPromotionProductRelation)
    {
        return smsFlashPromotionProductRelationMapper.updateSmsFlashPromotionProductRelation(smsFlashPromotionProductRelation);
    }

    /**
     * 批量删除商品限时购与商品关系
     *
     * @param ids 需要删除的商品限时购与商品关系ID
     * @return 结果
     */
    @Override
    public int deleteSmsFlashPromotionProductRelationByIds(Long[] ids)
    {
        return smsFlashPromotionProductRelationMapper.deleteSmsFlashPromotionProductRelationByIds(ids);
    }

    /**
     * 删除商品限时购与商品关系信息
     *
     * @param id 商品限时购与商品关系ID
     * @return 结果
     */
    @Override
    public int deleteSmsFlashPromotionProductRelationById(Long id)
    {
        return smsFlashPromotionProductRelationMapper.deleteSmsFlashPromotionProductRelationById(id);
    }
}
